package com.runen.infinitemovement.tool.map;

import android.graphics.Color;

import com.amap.api.maps.AMap;
import com.amap.api.maps.model.LatLng;
import com.amap.api.maps.model.Polyline;
import com.amap.api.maps.model.PolylineOptions;

import java.util.List;

/**
 * Create by LiaoDuanHong
 * Create on
 */
public class MapLineUtils {
    /**
     * 绘制自定义宽度虚线
     *
     * @param aMap
     * @param latLngs
     * @param color
     * @return
     */
    private static Polyline addPolylineWidthDotted(AMap aMap, List<LatLng> latLngs, String color) {
        if (aMap != null) {
            return addPolyline(aMap, latLngs, 20, true, color);
        }
        return null;
    }

    /**
     * 绘制自定义宽度实线
     *
     * @param aMap
     * @param latLngs
     * @param color
     * @return
     */
    private static Polyline addPolylineWidth(AMap aMap, List<LatLng> latLngs, String color) {
        if (aMap != null) {
            return addPolyline(aMap, latLngs, 20, true, color);
        }
        return null;
    }

    /**
     * 绘制默认宽度实线
     *
     * @param aMap
     * @param latLngs
     * @param color
     * @return
     */
    private static Polyline addPolylineDefaultWidth(AMap aMap, List<LatLng> latLngs, String color) {
        if (aMap != null) {
            return addPolyline(aMap, latLngs, 0, false, color);
        }
        return null;
    }

    /**
     * 绘制默认宽度虚线
     *
     * @param aMap
     * @param latLngs
     * @param color
     * @return
     */
    private static Polyline addPolylineDefaultWidthDotted(AMap aMap, List<LatLng> latLngs, String color) {
        if (aMap != null) {
            return addPolyline(aMap, latLngs, 0, true, color);
        }
        return null;
    }

    private static Polyline addPolyline(AMap aMap, List<LatLng> latLngs, int width, boolean dottedLine, String color) {
        if (aMap != null)
            return aMap.addPolyline(new PolylineOptions()
                    .addAll(latLngs)
                    .width(width != 0 ? width : 15)
                    .setDottedLine(dottedLine) //打开虚线
                    .color(Color.parseColor(color)));
        return null;
    }
}
